Skip to content

Complete plaintext local sandbox integration support - #710

Open
countradooku wants to merge 1 commit into
ably:mainfrom
countradooku:codex/complete-local-sandbox-harness
Open

Complete plaintext local sandbox integration support#710
countradooku wants to merge 1 commit into
ably:mainfrom
countradooku:codex/complete-local-sandbox-harness

Conversation

@countradooku

@countradooku countradooku commented Aug 24, 2026

Copy link
Copy Markdown

Summary

Builds on #708 by completing support for compatibility servers that provision a plaintext loopback child.

  • preserve the SDK logical endpoint, TLS, and fallback-host behavior while tunnelling allowlisted REST and Realtime test traffic to the provisioned child
  • make the JWT and stats fixtures configurable and route the internet-up probe locally
  • let the HTTP recorder wrap any RoundTripper and safely record transport failures with no response
  • document the opt-in environment variables and reject non-loopback child/probe targets plus unlisted logical hosts

The routing is enabled only with ABLY_LOCAL_PLAINTEXT_REALTIME=1. Cloud sandbox behavior and the direct ABLY_LOCAL_SANDBOX_URL mode remain available. No production SDK files or test assertions are changed.

Why

Directly replacing the logical endpoint with a local HTTP/WS address lets basic integration tests run, but changes the semantics of TLS and fallback tests. A few fixtures also continue to call public Ably services. This test-only routing keeps those test semantics intact while making the suite hermetic for a local compatibility server.

Verification

  • go test -tags=unit -count=1 ./...
  • go vet ./ably/... ./scripts/...
  • scripts/ci-generate.sh
  • full JSON integration suite against a local Sockudo sandbox: go test -tags=integration -p 1 -race -count=1 -timeout 30m ./... (80.2s)
  • full MessagePack integration suite against a fresh local Sockudo sandbox with the same race-enabled command (80.1s)

Summary by CodeRabbit

  • Documentation

    • Added guidance for running integration tests against a local compatibility sandbox, including configuration options, endpoint restrictions, and secure fallback behavior.
  • Tests

    • Expanded integration coverage for local sandbox environments using plaintext WebSocket connections.
    • Improved test routing for local REST, realtime, fallback, and statistics endpoints.
    • Added validation for safe loopback routing, endpoint restrictions, transport errors, and response recording.
    • Added support for configurable local JWT service endpoints.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b8224aee-b6ad-4044-918a-d239757dd500

📥 Commits

Reviewing files that changed from the base of the PR and between 26cb171 and 4df2615.

📒 Files selected for processing (9)
  • CONTRIBUTING.md
  • ably/export_test.go
  • ably/main_integration_test.go
  • ably/rest_channel_integration_test.go
  • ably/rest_client_integration_test.go
  • internal/ablytest/ablytest.go
  • internal/ablytest/recorders.go
  • internal/ablytest/sandbox.go
  • internal/ablytest/sandbox_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The integration harness now supports local compatibility sandboxes with restricted plaintext REST and Realtime routing. Tests can use configurable local endpoints, JWT creation, and stats fixtures. Transport recording now supports arbitrary round-trippers and nil responses.

Changes

Local sandbox routing

Layer / File(s) Summary
Transport hooks and recording
ably/export_test.go, internal/ablytest/recorders.go, internal/ablytest/sandbox_test.go
WebSocket URL transforms are synchronized. HTTP recording accepts any http.RoundTripper and handles nil responses.
Sandbox endpoint validation and routing
internal/ablytest/sandbox.go, internal/ablytest/sandbox_test.go, internal/ablytest/ablytest.go
Local sandbox endpoints are validated as loopback addresses. Approved REST traffic and Realtime traffic route through configured local endpoints. Tests cover routing, rejection, and recorder behavior.
Integration test endpoint wiring
ably/main_integration_test.go, ably/rest_channel_integration_test.go, ably/rest_client_integration_test.go, CONTRIBUTING.md
Integration tests support optional plaintext Realtime mode and configurable local child, JWT, internet-probe, REST, fallback, and stats endpoints. Documentation describes the required environment variables and restrictions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 4df26

This test-only change adds opt-in local sandbox routing without any identified merge-blocking risk; it is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant IntegrationTests
  participant Sandbox
  participant RESTTransport
  participant RealtimeDialer
  IntegrationTests->>Sandbox: provision local child
  Sandbox->>RESTTransport: configure approved REST routing
  IntegrationTests->>RealtimeDialer: install URL transform
  RESTTransport->>Sandbox: send rewritten HTTP request
  RealtimeDialer->>Sandbox: dial rewritten plaintext WebSocket
Loading

Suggested reviewers: simonwoolf, lmars

Poem

I’m a rabbit with routes in a burrow so neat,
Loopback hops carry each test on its feet.
REST hosts are checked, WebSockets turn bright,
Bad paths stay blocked through the cool moonlit night.
Local sandboxes now make the suite take flight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 8 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's main change: plaintext local sandbox integration support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant